package lightswitch.server.code.sqlhelper.statement.select;

import java.util.ArrayList;
import java.util.List;

import lightswitch.server.code.sqlhelper.expression.Column;
import lightswitch.server.code.util.StringHelper;

public class GroupBy {
	
	public List<Column> _columnList;
	
	public GroupBy()
	{
		
	}
	public GroupBy(String statement, From _from)
	{
		if(statement=="")
		{
			_columnList = new ArrayList<>();
			return;
		}
		statement = StringHelper.NormalizeString(statement);
		_columnList = new ArrayList<Column>();
		statement = statement.substring("select ".length()); 
		statement = StringHelper.NormalizeString(statement);
		String[] items = statement.split(",");
		for(int i=0;i<items.length;i++)
		{
			Column col  = new Column(items[i],_from);
			_columnList.add(col); 
		}
	}
	public String toString()
	{
		String t =" Group by ";
		t= t + " ";
		for(int i=0;i<_columnList.size();i++)
		{
			t = t +_columnList.get(i).toString() + " , " ;
		}
		return t+ "  ";
	}
	

}
